package collectionDemo.arraylistdemo;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;


public class Demo1 {
	public  void main(String[] args) {
		List<String> list1=new ArrayList<>();
		
		list1.add("1");
		list1.add(null);
		
		System.out.println(" before---"+list1.size());
		remove(list1);
		remove(list1);
		System.out.println(" after---"+list1.size());
		System.out.println(" after---"+(list1==null));
	}

	private static void remove(List<String> list1) {

		list1.remove(0);
		
	}

	@Test
	public void arraySort(){
		  CopyOnWriteArrayList<String> mPortsList = new CopyOnWriteArrayList<>();//存储端口 号
		mPortsList.add("usb1");
		mPortsList.add("usb5");
		mPortsList.add("usb2");
		mPortsList.add("usb7");
		mPortsList.add("usb6");
		ArrayList<String> tempList = new ArrayList<>(mPortsList);
		Collections.sort(tempList);
		mPortsList.clear();
		mPortsList.addAll(tempList);

		for (int i = 0; i < mPortsList.size(); i++) {
			System.out.println(mPortsList.get(i));
		}

	}
}
